package kr.co.handysoft.smartPolice.server.handler;

import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.Socket;

import net.sf.json.JSONObject;

public class ConnectionInformationSetupHandler implements IServerHandler{

	private Socket socket;

	public ConnectionInformationSetupHandler(Socket socket) {
		this.socket = socket;
	}

	
	public JSONObject getData() throws IOException {
		JSONObject retObject = null;
		InputStream is = this.socket.getInputStream();
		OutputStream os = this.socket.getOutputStream();
		BufferedReader bufferR = new BufferedReader(new InputStreamReader(is));
		BufferedWriter bufferW = new BufferedWriter(new OutputStreamWriter(os));
		bufferW.write("getInformation\r\n");
		bufferW.flush();
		String recvString = bufferR.readLine().trim();
		System.out.println("recvString : " + recvString);
		retObject = JSONObject.fromObject(recvString);
		bufferW.write("SUCCESS~!\r\n");
		bufferW.flush();
		return retObject;
	}

}
